package com.modbus.tcp.controller;

import java.util.List;

import com.modbus.tcp.utils.ApiReturnObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.modbus.tcp.domain.Stopfileposition;
import com.modbus.tcp.service.IStopfilepositionService;


/**
 * 灭火安装位置 信息操作处理
 *
 * @author d
 * @date 2024-01-11
 */
@RestController
@RequestMapping("/stopfileposition")
public class StopfilepositionController  {

    @Autowired
    private IStopfilepositionService stopfilepositionService;

    /**
     * 查询灭火安装位置列表
     */
    @GetMapping("/list")
    public ApiReturnObject list(Stopfileposition stopfileposition,Integer pageNum,Integer pageSize) {
        if(pageNum != null && pageSize !=null ){
            PageHelper.startPage(pageNum,pageSize);
        }
        List<Stopfileposition> list = stopfilepositionService.selectStopfilepositionList(stopfileposition);
        PageInfo pageInfo = new PageInfo<>(list);
        return new ApiReturnObject("200","查询成功",pageInfo);
    }


    /**
     * 新增保存灭火安装位置
     */

    @PostMapping("/add")
    public ApiReturnObject addSave(@RequestBody Stopfileposition stopfileposition) {
        stopfilepositionService.insertStopfileposition(stopfileposition);
        return new ApiReturnObject("200","添加成功","");
    }


    /**
    * 详情灭火安装位置
    */
    @GetMapping("/selectOne")
    public ApiReturnObject selectOne(Integer id){
        Stopfileposition result = stopfilepositionService.selectStopfilepositionById(id);
        return new ApiReturnObject("200","查询成功",result);
    }

    /**
     * 修改保存灭火安装位置
     */

    @PostMapping("/update")
    public ApiReturnObject editSave(@RequestBody Stopfileposition stopfileposition) {
        stopfilepositionService.updateStopfileposition(stopfileposition);
        return new ApiReturnObject("200","修改成功","");
    }

    /**
     * 删除灭火安装位置
     */

    @PostMapping("/del")
    public ApiReturnObject remove(String ids) {
        stopfilepositionService.deleteStopfilepositionByIds(ids);
        return new ApiReturnObject("200","删除成功","");
    }
}